{% extends 'base.twig' %}
{% block style %}
    <style>
        .table thead tr th{
            height:30px; line-height: 30px; text-align: center;}
        .table tbody tr td{
            height:30px; line-height: 30px; text-align: center;}
    </style>
    <link href="template/plugins/pnotify/css/pnotify.custom.css" rel="stylesheet" type="text/css">
    <script src="template/plugins/pnotify/js/pnotify.custom.js" type="text/javascript"></script>
{% endblock %}
{% block content %}
<section id="main-content">
    <section class="wrapper">
        <div class="row mt">
            <div class="col-lg-12">
                <div class="content-panel">
                    <h4><i class="fa fa-directory"></i> 所有产品  <a class="btn btn-success pull-right" href="user.php?act=edit"> 增加用户 </a></h4>
                    <section id="unseen">
                        <table class="table table-bordered ">
                            <thead>
                            <tr>
                                <th>id</th>
                                <th>用户名称</th>
                                <th>用户组</th>
                                <th>email</th>
                                <th>添加人</th>
                                <th>添加时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {% for g in goodsList %}

                                {% if g.email !="buguniao@qq.com" or  admin.email =="buguniao@qq.com"%}
                                <tr class="{% if g.is_del==1 %}bg-danger{% endif %}">
                                    <td>{{ g.uid }}</td>
                                    <td>{{ g.username }}</td>
                                    <td>{{ g.userGroup }}</td>
                                    <td>{{ g.email }}</td>
                                    <td>{{ g.add_user }}</td>
                                    <td>{{ g.add_time }}</td>
                                    <td>
                                        
                                        
                                        {% if g.is_del ==1 %}
                                               <a class="btn btn-success" onclick="delproduct({{ g.uid }},0);"><i class="fa fa-edit"></i> 恢复 </a>
                                            {% else %}
                                                <a class="btn btn-primary" href="user.php?uid={{ g.uid }}&act=edit"><i class="fa fa-edit"></i> 编辑</a>
                                                <a class="btn btn-danger"  onclick="delproduct({{ g.uid }},1);"><i class="fa fa-edit"></i> 删除 </a>
                                        {% endif %}
                                        </td>
                                </tr>
                                {% endif %}
                            {% endfor %}
                            </tbody>
                        </table>
    
                        <div class="text-center">
                            {{ pageHtml|raw }}
                        </div>
                    </section>
                </div>
            </div>
        </div>
    </section>
</section>
    
    <script type="text/javascript">
        highlight_subnav('user.php?');
        function delproduct(uid,is_del) {

            var url = 'user.php?' ;
            var json = {uid:uid,is_del:is_del,act:"delete"};
            if(confirm('确认进行此操作吗？'))
            {
                $.ajax({
                    url : url,
                    data : json,
                    type : "post",
                    dataType:"json",

                    success : function(data) {
                        if(data.ret)
                        {
                            location.reload()
                        }
                        else{
                            new PNotify({
                                title: '错误！！',
                                text: data.msg,
                                type: 'error',
                                addclass: 'stack-bar-top'
                            });
                        }

                    },
                    error:function(XMLHttpRequest, textStatus, errorThrown){
                        alert(errorThrown);
                    }

                });
            }
            
        }
    </script>
{% endblock %}
